package com.ruoyi.common.config;

import com.ruoyi.common.sms.biz.SMSClient;
import com.ruoyi.common.sms.biz.impl.AliyunSMSClient;
import com.ruoyi.common.sms.biz.impl.MockSMSClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * Created by rize on 2019/7/2.
 */
@Data
@Component
public class SMSConfig {

    @Value("${sms.enable}")
    private String enable;

    @Bean
    public SMSClient smsClient() {
         if ("aliyun".equals(enable)) {
            return new AliyunSMSClient();
        } else if ("mock".equals(enable)) {
            return new MockSMSClient();
        } else {
            return new MockSMSClient();
        }
    }
}
